import IConstants from "@/core/constants";
import IResponse from "@/services/response.service";
import { Injectable } from "@nestjs/common";
import axios, { AxiosProxyConfig } from "axios";
import { concatMap, defer, map, of } from "rxjs"
import * as https from "https"
import { FreeGpt35 } from "./free-gpt-35/FreeGpt35"

@Injectable()
export class ChatService {
  handleCompletions(body: any) {
    return new FreeGpt35().runCompletion(body)
  }

  getProxy(): AxiosProxyConfig {
    return {
      protocol: 'http',
      host: '127.0.0.1',
      port: 7890
    }
  }

  checkProxy() {
    return defer(() => 
      axios.get(`https://api.ipify.org/?format=json`, {
        proxy: this.getProxy()
      })
    ).pipe(
      map(d => d.data)
    )
  }

  getCookie() {
    return of(null).pipe(
      // concatMap(() => new FreeGpt35().bootstrap())
    )
  }
}

